define(function(require, exports, module){
	require("resource/js/easyui/themes/icon.css");
	require("resource/js/easyui/easyloader.js");
	var AJAX = require("resource/js/component/ajax.js");
	var EUtil = require("resource/js/component/easyutil.js");
		var dgutil = undefined;
	var config = {
		name:"施工车辆数据上传表",
		column:[[
			{field:'id',title:'主键',width:100,align:'center',height:50,hidden:true},
		
			{field:'type',title:'设备类型',width:100,align:'center',height:50,hidden:false},
		
			{field:'mac',title:'设备mac',width:100,align:'center',height:50,hidden:false},
		
			{field:'conId',title:'车辆id（tbl_dcs_sys_construction_vehicle表主键）',width:100,align:'center',height:50,hidden:true},
		
			{field:'lat',title:'经度',width:100,align:'center',height:50,hidden:false},
		
			{field:'lng',title:'纬度',width:100,align:'center',height:50,hidden:false},
		
			{field:'height',title:'高度',width:100,align:'center',height:50,hidden:false},
		
			{field:'ios',title:'离析度',width:100,align:'center',height:50,hidden:false},
		
			{field:'val1',title:'传感1（（其他）（null-为接入设备，error-设备数据未采集到，数字-数据））',width:100,align:'center',height:50,hidden:true},
		
			{field:'val2',title:'传感2（（其他）（null-为接入设备，error-设备数据未采集到，数字-数据））',width:100,align:'center',height:50,hidden:true},
		
			{field:'val3',title:'传感3（（其他）（null-为接入设备，error-设备数据未采集到，数字-数据））',width:100,align:'center',height:50,hidden:true},
		
			{field:'val4',title:'传感4（（其他）（null-为接入设备，error-设备数据未采集到，数字-数据））',width:100,align:'center',height:50,hidden:true},
		
			{field:'val5',title:'传感5（（其他）（null-为接入设备，error-设备数据未采集到，数字-数据））',width:100,align:'center',height:50,hidden:true},
		
			{field:'val6',title:'传感6（（其他）（null-为接入设备，error-设备数据未采集到，数字-数据））',width:100,align:'center',height:50,hidden:true},
		
			{field:'val7',title:'传感7（（其他）（null-为接入设备，error-设备数据未采集到，数字-数据））',width:100,align:'center',height:50,hidden:true},
		
			{field:'val8',title:'传感8（（其他）（null-为接入设备，error-设备数据未采集到，数字-数据））',width:100,align:'center',height:50,hidden:true},
		
			{field:'val9',title:'传感9（（其他）（null-为接入设备，error-设备数据未采集到，数字-数据））',width:100,align:'center',height:50,hidden:true},
		
			{field:'time',title:'时间',width:100,align:'center',height:50,hidden:false},
		
			{field:'issyc',title:'时间是否同步（0未同步1同步）',width:100,align:'center',height:50,hidden:true},
		
			{field:'satNum',title:'卫星个数',width:100,align:'center',height:50,hidden:true},
		
			{field:'difData',title:'差分标识（标识定位数据是否差分（0未差分1有差分））',width:100,align:'center',height:50,hidden:true},
		
			{field:'data',title:'差分数据等级（"表示差分数据的经度等级（0-没有定位原始数据；1-自主定位，偏差比较大；2-亚米级定位（误差小于1m）；4-厘米级定位（最精确的）计算遍数；5-浮动级定位（几厘米到几米不等））"）',width:100,align:'center',height:50,hidden:true},
		
			{field:'seq',title:'设备序号',width:100,align:'center',height:50,hidden:true},
		
			{field:'a1',title:'振幅3（单位mm，保留小数点后两位）',width:100,align:'center',height:50,hidden:true},
		
			{field:'a2',title:'振幅3（单位mm，保留小数点后两位）',width:100,align:'center',height:50,hidden:true},
		
			{field:'a3',title:'振幅3（单位mm，保留小数点后两位）',width:100,align:'center',height:50,hidden:true},
		
			{field:'gx',title:'三维加速度x(单位g，范围+/-2.000)',width:100,align:'center',height:50,hidden:true},
		
			{field:'gy',title:'三维加速度y(单位g，范围+/-2.000)',width:100,align:'center',height:50,hidden:true},
		
			{field:'gz',title:'三维加速度z(单位g，范围+/-2.000)',width:100,align:'center',height:50,hidden:true},
		
			{field:'isHandler',title:'是否处理0未处理1已处理',width:100,align:'center',height:50,hidden:true},
		
			{field:'createTime',title:'数据库创建时间',width:100,align:'center',height:50,hidden:false},
		]]
	}
	
	var initpage = function(){
		dgutil = EUtil.ajaxDataGrid(datagridconfig);
	}
	var initFiledByForm = function(rows,id){
		var validate = true;
		if(typeof rows == "boolean"){
			validate = rows;
		}
	}

	var addDialogInit = function(url){
		$("#editdlg").dialog({
			title:config.name+"增加",
			href:url,
			onLoad:function(){
				initFiledByForm(false,'add');
		    },
			buttons: [{
				text:'保存',
				iconCls:'icon-ok',
				accessKey:{akey:18,mkey:83},
				handler:function(){
					using(["form"],function(){
						if($("#editform").form("validate")){
							var obj = $("#editform").serializeJson();
							AJAX.init().success(function(code,msg,data){
								$.messager.show({ title:"系统提示", msg:msg, timeout:2000, showType:'slide' });
								dgutil.pager();
								$("#editdlg").dialog("close");
		    	    		}).error(function(code,msg,data){
		    	    			$.messager.alert("系统提示", msg, "error");
		    	    		}).contentType('application/json').post(BASEPATH+"/dcs/paver/construction/saveDataPaverConstruction.htm",JSON.stringify(obj));
						}
					});
				}
			},{
				text:'取消',
				addClass:'l-btn-red',iconCls:'icon-not',
				accessKey:{akey:18,mkey:67},
				handler:function(){
					$('#editdlg').dialog('close');
				}
			}]
		});
		$("#editdlg").dialog("open");
	}
	var updDialogInit = function(url,row){
		$("#editdlg").dialog({
			iconCls: 'icon-save',
			title:config.name+'修改',
			href:url,
			onLoad:function(){
				initFiledByForm(row,'upd');
				$("#editform").form("load",row);
		    },
			buttons: [{
				text:'保存',
				iconCls:'icon-ok',
				accessKey:{akey:18,mkey:83},
				handler:function(){
					using(["form"],function(){
						if($("#editform").form("validate")){
							var obj = $("#editform").serializeJson();
							AJAX.init().success(function(code,msg,data){
								$.messager.show({ title:"系统提示", msg:msg, timeout:2000, showType:'slide' });
								dgutil.pager();
								$("#editdlg").dialog("close");
		    	    		}).error(function(code,msg,data){
		    	    			$.messager.alert("系统提示", msg, "error");
		    	    		}).contentType('application/json').post(BASEPATH+'/dcs/paver/construction/updateDataPaverConstruction.htm',JSON.stringify(obj));
						}
					});
				}
			},{
				text:'取消',
				addClass:'l-btn-red',iconCls:'icon-not',
				accessKey:{akey:18,mkey:67},
				handler:function(){
					$('#editdlg').dialog('close');
				}
			}]
		});
		$("#editdlg").dialog("open");
	}
	var delInit = function(url,rows){
		var checks = [];
		for(var key in rows){
			var id = '' +rows[key].id;
			checks.push(id);
		}
		EUtil.ajaxHandler(url,{checkeds:checks.join(",")},function(){
			dgutil.delRow(rows);
		});
	}
	module.exports = {
		trans:function(){
			var buttons ={ 
				title:{
					_class:"",
					text:"施工车辆数据上传表列表"
				},
				btn:[
					 {
						 iconCls: 'icon-search',
						 url:'/dcs/paver/construction/queryDataPaverConstructionByPage.htm',
						 text:"查询",
						 //addClass:'l-btn-display',
						 btnType: 'searchBtn',
						 handler: function(){dgutil.pager(1);}
					 },
					 {
						 iconCls: 'icon-add',
						// addClass:'l-btn-display',
						 text:"添加",
						 url:'/view/dcs/paver/construction/datapaverconstructionadd',
						 handler: addDialogInit
					 },
					 {
						 iconCls: 'icon-edit',
						 url:'/view/dcs/paver/construction/datapaverconstructionupd',
						 text:"修改",
						// addClass:'l-btn-display',
						 needRow:true,
						 handler: updDialogInit
					 },
					 {
						 iconCls: 'icon-remove',
						 url:'/dcs/paver/construction/deleteDataPaverConstruction.htm',
						 text:"删除",
						// addClass:'l-btn-display',
						 needRows:true,
						 isCheck:true,
						 handler: delInit
					 }
				]};
			datagridconfig = {
				fitColumns:true,
				singleSelect:false,
				striped:true,
				autoRowHeight:false,
				fit: true,
				toolbar:buttons,
				columns:config.column,
				eid:"dg",
				url:BASEPATH+'/dcs/paver/construction/queryDataPaverConstructionByPage.htm',
				args:"searchform"
			};
			
			using(["parser","dialog","datagrid","combobox" ],function(){
				initpage();
			});
		}
	}
});
